#include "screenEater.h"

polaris::eater::eater(int w, int h)
{
    out = SDL_CreateRGBSurface(NULL, w, h,32, 0xff0000, 0x00ff00, 0x0000ff, 0x000000);
}

void polaris::eater::eat1(SDL_Surface *in)
{
    for(int x = 0; x<in->w; x++)
    {
        for(int y = 0; y < in->h; y+=2)
        {
            Uint32 *color1 = (Uint32 *)in->pixels + y*in->pitch/4 + x;
            Uint32 *color2 = (Uint32 *)out->pixels + (y/2)*out->pitch/4 + x;

            *color2 = *color1;
        }
    }

}

void polaris::eater::eat2(SDL_Surface *in)
{
    for(int x = 0; x<in->w; x++)
    {
        for(int y = 0; y < in->h; y+=2)
        {
            Uint32 *color1 = (Uint32 *)in->pixels + y*in->pitch/4 + x;
            Uint32 *color2 = (Uint32 *)out->pixels + (y/2 +in->h/2)*out->pitch/4 + x;

             if(y==0) *color2 = 0x0ff00;

            else *color2 = *color1;

        }

    }
}
